/************************* 版权声明 *********************************
 * 
 * 版权所有：Apache License 2.0
 * 
 ************************* 版本声明 *********************************
 *@since jdk1.5
 *@version 0.1
 ************************* 变更记录 *********************************
 *
 * 创建者：bijiqiang Email:bijiqiang@gmail.com   创建日期： 2010-1-22
 * 创建记录：创建类结构。
 * 
 * 修改者：       修改日期：
 * 修改记录：
 *
 * 修改者：       修改日期：
 * 修改记录：
 * ……
 ************************* To  Do *********************************
 *
 * 1、实现所有未实现的方法（抛出UnsupportedOperationException的方法）。
 * 
 ************************* 随   笔 *********************************
 *
 * 
 * 
 ******************************************************************
 */

package com.realgodo.site.web.admin.show;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springside.modules.orm.Page;

import com.realgodo.site.entity.application.show.ShowCatalog;
import com.realgodo.site.service.application.ShowCatalogManager;
import com.realgodo.site.web.admin.AdminDefaultController;

@Scope("prototype")
@Results( { @Result(name = "toindex", type = "redirect", location = "${base}/admin/show/catalog/") })
public class CatalogController extends AdminDefaultController {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2341341949108506678L;

	@Autowired
	private ShowCatalogManager showCatalogManager;

	private ShowCatalog showCatalog;
	
	private Page<ShowCatalog> showCatalogPage = new Page<ShowCatalog>(PAGE_SIZE);

	public String index() throws Exception {
		showCatalogPage.setPageNo(showCatalogManager.isParamNotNull(
				getParamMap(), Page.PAGE) ? Integer
				.valueOf((String) showCatalogManager.getParamValue(
						getParamMap(), Page.PAGE)) : 1);// 查询页数
		showCatalogPage = this.showCatalogManager
				.findShowCatalogs(showCatalogPage);
		super.setPageInfo(showCatalogPage);
		return SUCCESS;
	}

	public String edit() {
		if (null != getId()) {
			showCatalog = this.showCatalogManager.get(getId());
		}
		return "edit";
	}

	public String save() throws Exception {
		this.showCatalogManager.save(showCatalog);
		return "toindex";
	}

	public Page<ShowCatalog> getShowCatalogPage() {
		return showCatalogPage;
	}

	public void setShowCatalogPage(Page<ShowCatalog> showCatalogPage) {
		this.showCatalogPage = showCatalogPage;
	}

	public ShowCatalog getShowCatalog() {
		return showCatalog;
	}

	public void setShowCatalog(ShowCatalog showCatalog) {
		this.showCatalog = showCatalog;
	}
}
